package project.configuration.instructions;

import project.events.packageEvents.PackageCreatedEvent;
import project.layer.physical.Crossroad;
import project.layer.physical.Package;

import framework.events.EventBroker;
import framework.instructions.creation.CreateInstruction;


public class CreatePackageInstruction extends CreateInstruction {

	private int id;
	
	private Crossroad origin;
	private Crossroad destination;

	public CreatePackageInstruction(long executionTime, int objectId, Crossroad origin, Crossroad destination) {
		super(executionTime, objectId);
		this.origin = origin;
		this.destination = destination;
		this.id = objectId;
	}
	
	@Override
	protected Object createObject() {
		Package pack = new Package(id, origin, destination);
		EventBroker.getEventBroker().notifyAll(new PackageCreatedEvent(pack, origin.getPosition(), this.origin));
		return pack;
	}
}





